﻿<%@ page language="java" import="java.util.*"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%
String path = request.getContextPath();
String app_version = net.zoneland.greenleaf.GLOBAL.APP_VERSION;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=10;IE=9;IE=8;" />	
  		<!-- Title and other stuffs -->
  		<title>后台管理系统</title> 
  		<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  		<script src="<%=path %>/js/greenleaf/jquery-1.8.3.js"></script> <!-- jQuery -->		
  		<script type="text/javascript">
	  		var path = "<%=path %>";
	  		var app_version = "<%=app_version %>";  
  		</script>
 </head>
 <body>
<div id="mainbar" class="mainbar">
 <!-- Page heading -->
	<div class="page-head">
	    <h2 class="pull-left"><i class="icon-home"></i> 任务执行日志</h2>
        <!-- Breadcrumb -->
        <div class="bread-crumb pull-right">
          <a href="<%=path %>/pages/ui/index.jsp"><i class="icon-home"></i> 定时任务管理</a> 
          <!-- Divider -->
          <span class="divider">/</span> 
          <a href="#" class="bread-current">任务执行日志</a>
        </div>
        <div class="clearfix"></div>
	</div>
	<!-- Page heading ends -->

	<!-- Matter -->
	<div class="matter">
        <div class="container">
        <!-- 页面的内容开始. -->
        <!-- Table -->
            <div class="row">
              <div class="col-md-12">
                <div class="widget">
                <div class="widget-head">
                  <div class="pull-left">任务执行日志列表</div>
                  <div class="widget-icons pull-right">
                    	<!-- 这里是标题栏靠右显示内容，如最大最小化按钮 -->
                  </div>  
                  <div class="clearfix"></div>
                </div>
                  <div class="widget-content">
                    <table class="table table-striped table-bordered table-hover">
                      <thead>
                        <tr>
							<th>代理名称</th>
							<th>线程名称</th>
							<th>线程ID</th>
							<th>开始时间</th>
							<th>结束时间</th>
							<th>持续时间</th>
                        </tr>
                      </thead>
                      <tbody id="timer_runlog_list_tbody"></tbody>
                    </table>
                    <div class="widget-foot">
                        <ul class="pagination pull-right">
                          <div class="pagination" id="timer_runlog_pagination"></div> <!-- End .pagination -->
                        </ul>                     
                      <div class="clearfix"></div> 
                    </div>
                  </div>
                </div>
              </div>
            </div>
        <!-- 页面的内容结束. -->
        </div>
	</div>
	<!-- Matter ends -->
</div>
<script src="<%=path %>/js/greenleaf/actions/timer_runlog_action.js"></script>
<script type="text/javascript">
var timer_runlog_list_currentpage = 1, timer_runlog_list_pagesize = 20, timer_runlog_list_maxpage = 1;

$(document).ready(function(){
		get_timer_runlog_list("first");
});

//查询所有的任务信息列表方法实现
function get_timer_runlog_list(page_flag, fn){
	var url = timer_runlog_info_action.service.list;
	if("first"==page_flag){
		timer_runlog_list_currentpage = 1;
	}else if("last"==page_flag){
		timer_runlog_list_currentpage = timer_runlog_list_maxpage;
	}else if("next"==page_flag){
		if(timer_runlog_list_currentpage < timer_runlog_list_maxpage){
			++timer_runlog_list_currentpage;
		}
	}else if("preview"==page_flag){
		if(timer_runlog_list_currentpage >1){
			--timer_runlog_list_currentpage;
		}
	}		
	var paramMap = {};
	paramMap.page = timer_runlog_list_currentpage;
	paramMap.pagesize = timer_runlog_list_pagesize;
	var json_data = JSON.stringify(paramMap);
	$.getJSON(url, {"jsonstring":json_data}, function(json){
			var timer_runlog_list_html = "";
			timer_runlog_list_maxpage = json.pagination.totalPage;
			$(json.list).each(function(){
				timer_runlog_list_html += "<tr>";	             	
				timer_runlog_list_html += "<td>"+this.timer_name+"</td>";
				timer_runlog_list_html += "<td>"+this.thread_name+"</td>";
				timer_runlog_list_html += "<td>"+this.thread_id+"</td>";
				timer_runlog_list_html += "<td>"+this.call_starttime+"</td>";
				timer_runlog_list_html += "<td>"+this.call_endtime+"</td>";
				timer_runlog_list_html += "<td>"+this.call_continued+"</td>";	             	
            	timer_runlog_list_html += "</tr>"
			});
			$("#timer_runlog_list_tbody").html(timer_runlog_list_html);
			
			var timer_pagination_html = "<li><a href=\"javascript:get_timer_runlog_list('first')\" title=\"First Page\">首页</a></li><li><a href=\"javascript:get_timer_runlog_list('preview')\" title=\"Previous Page\">上一页</a></li>";
			var count=0;
			for(var i=timer_runlog_list_currentpage-3; i<=timer_runlog_list_maxpage && i<timer_runlog_list_currentpage+7 && count <7; i++){
				if(i > 0){
					if(i==timer_runlog_list_currentpage-3){
						if(timer_runlog_list_currentpage > 3){
							timer_pagination_html += "<li><a href='javascript:void(0)'>...</a></li>";
							count++;
							continue;
						}
					}
					timer_pagination_html += "<li><a href=\"javascript:timer_runlog_list_currentpage="+i+";get_timer_runlog_list()\" class=\"number ";
					if(timer_runlog_list_currentpage == i){
						timer_pagination_html += "current";
					}						
					timer_pagination_html += " title=\""+i+"\">"+i+"</a></li>";
					count++;
				}
			}
			if(timer_runlog_list_maxpage>timer_runlog_list_currentpage+3){
				timer_pagination_html += "<li><a href='javascript:void(0)'>...</a></li>";
				timer_pagination_html += "<li><a href=\"javascript:timer_runlog_list_currentpage="+timer_runlog_list_maxpage+";get_timer_runlog_list()\" class=\"number ";
				if(timer_runlog_list_currentpage == timer_runlog_list_maxpage){
					timer_pagination_html += "current";
				}						
				timer_pagination_html += " title=\""+timer_runlog_list_maxpage+"\">"+timer_runlog_list_maxpage+"</a><li>";
			}					
			timer_pagination_html += "<li><a href=\"javascript:get_timer_runlog_list('next')\" title=\"Next Page\">下一页</a></li><li><a href=\"javascript:get_timer_runlog_list('last')\" title=\"Last Page\">末页</a></li>";
			$("#timer_runlog_pagination").html(timer_pagination_html);
			
			if(fn){fn();}
	 });
}
</script>
</body>